package top.txl.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import top.txl.entity.AddressBook;

import java.util.List;

@Mapper
public interface AddressBookMapper {

//    @Select("insert into address_book(user_id, consignee, sex, phone, detail, label, create_time, update_time, create_user, update_user) " +
//            "values(#{userId},#{name},#{sex},#{phone},#{detail},#{label},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void addBook(AddressBook book);

    List<AddressBook> getBookLists(Integer userId);

//    @Select("update address_book set user_id=#{userId}, consignee=#{name}, sex=#{sex}, phone=#{phone}, detail=#{detail}, label=#{label}, update_time=#{updateTime},update_user=#{updateUser}")
    void updateBook(AddressBook book);

//    @Select("select id, user_id userId, consignee, sex, phone,detail, label, is_default isDefault from address_book where user_id=#{userId} and id=#{id}")
    AddressBook getBookDetail(Integer userId, Integer id);

    void updateBookNotEqualThisId(AddressBook book);

    List<AddressBook> getIsDefaultAddress(Integer userId);
}
